<!DOCTYPE html>
<html lang="en">
<title>数据中心</title>
<#import "/layout/layout.html" as body/>
<@body.page>

<style>
    .modal-loading { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10000; background: rgba(0, 0, 0, .5) url("${baseUrl}img/loading.gif") no-repeat center; }
</style>
<div class="modal-loading"></div>
<h1>大盘数据</h1>

<!--按日期数据-->
<section class="wrapper wrapper-content animated fadeInUp">
    <div class="overflow">
        <h2 class="pull-left" id="dateTime">按日期数据（2017.03.13）</h2>
        <form class="form-inline pull-right" role="form" style="margin: 15px 0">
            <div data-toggle="buttons" class="btn-group">
                <label class="btn btn-sm btn-white active"> <input type="radio" id="option1" name="options" value="1" checked="checked"> 按天 </label>
                <label class="btn btn-sm btn-white"> <input type="radio" id="option2" name="options" value="2"> 按周 </label>
                <label class="btn btn-sm btn-white"> <input type="radio" id="option3" name="options" value="3"> 按月 </label>
            </div>
            <div class="form-group">
                <input type="text" class="form-control" id="exampleInputEmail" placeholder="按日期查询" readonly="readonly" value="${dateTime!}">
                <input type="text" class="form-control week" id="Week" placeholder="按周查询" style="display: none" readonly="readonly" value="${dateTime!}" >
                <input type="text" class="form-control year_month" id="yearMonth" placeholder="按月查询" style="display: none" readonly="readonly" value="${dateTime!}" >
            	<input type="hidden" id="types" name="types" value="${type!1}">
            </div>
            <button type="button" class="btn btn-default" id="btn_query">查询</button>
        </form>
    </div>
    <div class="row">
        <!--1111111111-->
        <div class="col-lg-3 col-sm-6 fangda_div">
            <div class="ibox float-e-margins" id="orderCount_div">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>当期零售订单笔数</h5>
                    <span class="label label-success pull-right btn btn-sm" id="orderCount_xq" onclick="quertOrderXQ('orderCount','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="orderCount">${orderCount!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins" id="orderWater_div">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>当期零售流水</h5>
                    <span class="label label-info pull-right btn btn-sm" id="orderWater_xq" onclick="quertOrderAmt('orderWater','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="orderWater">${orderWater!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins" id="orderRevenueAmt_div">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>当期零售实收金额</h5>
                    <span class="label label-primary pull-right btn btn-sm" id="orderRevenueAmt_qx" onclick="quertOrderAmt('orderRevenueAmt','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="orderRevenueAmt">${orderRevenueAmt!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins" id="orderPayNumber_div">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>当期付费总人数</h5>
                    <span class="label label-warning pull-right btn btn-sm open_modal" id="orderPayNumber_qx" onclick="quertOrderXQ('orderPayNumber','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="orderPayNumber">${orderPayNumber!0}</h1>
                </div>
            </div>
        </div>
        <!--222222222222-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>当期新增会员</h5>
                    <span class="label label-success pull-right btn btn-sm open_modal" onclick="quertOrderVip('vipNum','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipNum">${vipNum!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>当期新增会员流水</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderVip('vipWater','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipWater">${vipWater!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>当期会员实收</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipAmt','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipAmt">${vipAmt!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>当期流失会员数</h5>
                    <span class="label label-warning pull-right btn  btn-sm open_modal" onclick="quertVipLost('vipLost','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipLost">${vipLost!0}</h1>
                </div>
            </div>
        </div>
        <!--33333333333333-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>当期会员零售转化率</h5>
                    <span class="label label-success pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipConversionRate','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipConversionRate">${vipConversionRate!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>当期会员自助转化率</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipSelfConversionRate','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipSelfConversionRate">${vipSelfConversionRate!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>当期零售复购率</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderRate('retailRechargeRate','0');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="retailRechargeRate">${retailRechargeRate!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>当期排课量</h5>
                    <span class="label label-warning pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('courseCount','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="courseCount">${courseCount!0}</h1>
                </div>
            </div>
        </div>
        <!--44444444444444-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>当期团课满课率</h5>
                    <span class="label label-success pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('teamFullClassRate','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="teamFullClassRate">${teamFullClassRate!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>当期用户平均购买次数</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('averagePayCount','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="averagePayCount">${averagePayCount!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins" id="vip_jl">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>当期教练课时费</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('coachAmt','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="coachAmt">${coachAmt!0}</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins" id="vip_xf">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>当期会员续费率(仅月有)</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipRenewalFeeRate','0')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="vipRenewalFeeRate">${vipRenewalFeeRate!0}</h1>
                </div>
            </div>
        </div>
    </div>
</section>
<!--大盘数据模态框-->
<div class="modal fade bs-example-modal-lg-1" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
     aria-hidden="true">
    <div class="modal-dialog modal-lg" style="margin-top: 200px">
        <div class="modal-content" style="padding: 20px">
            <h3 id="dpxq">实收明细</h3>
            <ul class="folder-list m-b-md category-list" id="daxq_sj" style="padding: 0"></ul>
        </div>
    </div>
</div>
<!--大盘数据模态框-->
<!--汇总类数据-->
<section class="wrapper wrapper-content animated fadeInUp">
    <div class="overflow">
        <h2 class="pull-left">汇总类数据（2016.11.01至当前的数据汇总）</h2>
        <form class="form-inline pull-right" role="form" style="margin: 15px 0">
            <button type="button" class="btn btn-default" id="click_hz">点击查询</button>
        </form>
    </div>
    <div class="row animated fadeInUp" style="display: none;" id="hz_data_box">
        <!--1111111111-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>零售订单总笔数</h5>
                    <span class="label label-success pull-right btn btn-sm" onclick="quertOrderXQ('orderCount','1');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_orderCount">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>零售总流水</h5>
                    <span class="label label-info pull-right btn btn-sm" onclick="quertOrderAmt('orderWater','1')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_orderWater">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>零售总实收</h5>
                    <span class="label label-primary pull-right btn btn-sm" onclick="quertOrderAmt('orderRevenueAmt','1');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_incomeAmt">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>付费总人数</h5>
                    <span class="label label-warning pull-right btn btn-sm open_modal" onclick="quertOrderXQ('orderPayNumber','1');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_payCount">0</h1>
                </div>
            </div>
        </div>
        <!--222222222222-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>当前在线会员总数</h5>
                    <!-- <span class="label label-success pull-right btn btn-sm open_modal" onclick="quertUserStortCount('vipCount','1');">查看详情</span> -->
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipCount">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>会员总流水</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderVip('vipWater','1');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipWater">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>会员总实收</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipAmt','1')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipAmt">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>会员续费率</h5>
                    <span class="label label-warning pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipRenewalFeeRate')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipRenewalFeeRate">0</h1>
                </div>
            </div>
        </div>
        <!--33333333333333-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>流失会员总数</h5>
                    <span class="label label-success pull-right btn  btn-sm open_modal" onclick="quertVipLost('vipLost','1')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipLost">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>会员零售转化率</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipConversionRate')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipRetailRate">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 3 -->
                    <h5>会员自助转化率</h5>
                    <span class="label label-primary pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('vipSelfConversionRate')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_vipSelfRetailRate">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 4 -->
                    <h5>零售复购率</h5>
                    <span class="label label-warning pull-right btn  btn-sm open_modal" onclick="quertOrderRate('retailRechargeRate','1');">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_retailRate">0</h1>
                </div>
            </div>
        </div>
        <!--44444444444444-->
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 1 -->
                    <h5>团课平均满课率</h5>
                    <span class="label label-success pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('teamFullClassRate')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_teamFullClassRate">0</h1>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <!-- 2 -->
                    <h5>用户平均购买次数</h5>
                    <span class="label label-info pull-right btn  btn-sm open_modal" onclick="quertOrderZhuShi('averagePayCount')">查看详情</span>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" id="hz_averagePayCount">0</h1>
                </div>
            </div>
        </div>
    </div>
</section>

<!--排行类数据-->
<section class="wrapper wrapper-content animated fadeInUp">
    <div class="overflow">
        <h2 class="pull-left">排行类数据</h2>
        <form class="form-inline pull-right" role="form" style="margin: 15px 0">
            <button type="button" class="btn btn-default" id="click_ph">点击查询</button>
        </form>
    </div>
    <div class="row animated fadeInUp" style="display: none;" id="ph_data_dox">
        <div class="col-lg-4 col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>教练重复购买率排名</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="m-b-xs form-inline">
                        <div class="input-group">
                            <input type="text" placeholder="请选择日期查询" class="input-sm form-control check_date" id="sort_datarange1">
                        </div>
                        <button type="button" class="btn btn-sm btn-default" onclick="queryCoachSortData();">查询</button>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>排名</th>
                                <th>教练</th>
                                <th>百分比(%)</th>
                            </tr>
                            </thead>
                            <tbody id="coachDataDiv">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>课程重复购买率排名</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="m-b-xs form-inline">
                        <div class="input-group">
                            <input type="text" placeholder="请选择日期查询" class="input-sm form-control check_date" id="sort_datarange2">
                        </div>
                        <button type="button" class="btn btn-sm btn-default" onclick="queryCourseSortData();"> 查询</button>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>排名</th>
                                <th>课程</th>
                                <th>百分比(%)</th>
                            </tr>
                            </thead>
                            <tbody id="courseDataDiv">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>团课满课率排名</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="m-b-xs form-inline">
                        <div class="input-group">
                            <input type="text" placeholder="请选择日期查询" class="input-sm form-control check_date" id="sort_datarange3">
                        </div>
                        <button type="button" class="btn btn-sm btn-default" onclick="queryTeamFullClassRateSort();"> 查询</button>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>排名</th>
                                <th>课程</th>
                                <th>百分比</th>
                            </tr>
                            </thead>
                            <tbody id="teamCourseDataDiv">
                            </tbody>
                        </table>
                        <!-- <div class="ibox-footer overflow">
                                    <h4 class="pull-left" id="u_shifu" style="color: #2fb146">课程数量：10</h4>
                                    <div class="pull-right copot-page" id="u_page_list"></div>
                       </div> -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript" src="${baseUrl}js/data/data_index.js"></script>
<script>
    $(function () {
        $('.check_date').daterangepicker({
            startDate: moment().startOf('day'),
            endDate: moment(),
            //minDate: '01/01/2012',    //最小时间
            //maxDate: moment(), //最大时间
            dateLimit: {days: 365}, //起止时间的最大间隔
            showDropdowns: true,
            showWeekNumbers: false, //是否显示第几周
            timePicker: false, //是否显示小时和分钟
            timePickerIncrement: 60, //时间的增量，单位为分钟
            timePicker12Hour: false, //是否使用12小时制来显示时间
            ranges: {
                //'最近1小时': [moment().subtract('hours',1), moment()],
                // '今日': [moment().startOf('day'), moment()],
                // '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                '最近7日': [moment().subtract('days', 6), moment()],
                '最近30日': [moment().subtract('days', 30), moment()]
            },
            opens: 'right', //日期选择框的弹出位置
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary blue',
            cancelClass: 'btn-small',
            format: 'YYYY-MM-DD', //控件中from和to 显示的日期格式 YYYY-MM-DD HH:mm:ss
            separator: '~',
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        }, function (start, end, label) {//格式化日期显示框
            $('.check_date span').html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
        });

        $('#exampleInputEmail').daterangepicker({
            startDate: moment().startOf('day'),
            endDate: moment(),
            dateLimit: {days: 365}, //起止时间的最大间隔
            showDropdowns: true,
            showWeekNumbers: false, //是否显示第几周
            timePicker: false, //是否显示小时和分钟
            timePickerIncrement: 60, //时间的增量，单位为分钟
            timePicker12Hour: false, //是否使用12小时制来显示时间
            ranges: {
                //'最近1小时': [moment().subtract('hours',1), moment()],
                '今日': [moment().startOf('day'), moment()],
                '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                '最近7日': [moment().subtract('days', 6), moment()],
                '最近30日': [moment().subtract('days', 30), moment()]
            },
            opens: 'left', //日期选择框的弹出位置
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary blue',
            cancelClass: 'btn-small',
            format: 'YYYY-MM-DD', //控件中from和to 显示的日期格式 YYYY-MM-DD HH:mm:ss
            separator: '~',
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        }, function (start, end, label) {//格式化日期显示框
            $('#exampleInputEmail span').html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
        });

        $('#Week').daterangepicker({
            autoApply: true,
            showDropdowns: true,
            showWeekNumbers: true, //是否显示第几周
            ranges: {
                '最近1周': [moment().subtract('weeks', 1), moment()],
                '最近3周': [moment().subtract('weeks', 3), moment()],
                '最近5周': [moment().subtract('weeks', 5), moment()]
            },
            opens: 'left', //日期选择框的弹出位置
            format: 'YYYY-MM-DD', //控件中from和to 显示的日期格式 YYYY-MM-DD HH:mm:ss
            separator: '~',
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                weekLabel: '周',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        }, function (start, end, label) {//格式化日期显示框
            $('#Week span').html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
        });
        $('#yearMonth').datetimepicker({
            language: 'zh-CN',
            weekStart: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 3,
            forceParse: 0,
            showMeridian: 0,
            minView: "year",
            format: "yyyy-mm"
        });

        $(".btn-white").click(function () {
            var op = $(this).children().attr("id");
            if (op == "option1") {
                $("#exampleInputEmail").show();
                $("#Week,#yearMonth").hide();
                $("#exampleInputEmail").val();
                $("#exampleInputEmail").val(moment().startOf('day').format('YYYY-MM-DD')+'~'+moment().startOf('day').format('YYYY-MM-DD'));
                $("#types").val(1);
            } else if (op == "option2") {
                $("#Week").show();
                $("#exampleInputEmail,#yearMonth").hide();
                $("#Week").val(moment().subtract('weeks', 1).startOf('day').format('YYYY-MM-DD') + '~' +moment().startOf('day').format('YYYY-MM-DD'));
                $("#types").val(2);
            } else if (op == "option3") {
                $("#yearMonth").show();
                $("#Week,#exampleInputEmail").hide();
                var yearMonth = $("#yearMonth").val();
                $("#yearMonth").val(moment().format('YYYY-MM'));
                $("#types").val(3);
            }
            data_level_one();
        });

        // 汇总类数据
        $("#click_hz").click(function () {
            $("#hz_data_box").show();
            $('.modal-loading').show();
            // 
            $("#hz_orderCount").html("");
            $("#hz_orderWater").html("");
            $("#hz_incomeAmt").html("");
            $("#hz_payCount").html("");

            $("#hz_vipCount").html("");
            $("#hz_vipWater").html("");
            $("#hz_vipAmt").html("");
            $("#hz_vipRenewalFeeRate").html("%");

            $("#hz_vipLost").html("");
            $("#hz_vipRetailRate").html("%");
            $("#hz_vipSelfRetailRate").html("%");
            $("#hz_retailRate").html("%");

            $("#hz_teamFullClassRate").html("%");
            $("#hz_averagePayCount").html("");
            
            // 汇总类数据
            $.ajax({
                url: 'summary_data_to_date',
                data: {},
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    
                    if (data.ret == 0) {
                        var datas = data.data;
                        $("#hz_orderCount").html(datas.orderCount);
                        $("#hz_orderWater").html(datas.orderWater);
                        $("#hz_incomeAmt").html(datas.incomeAmt);
                        $("#hz_payCount").html(datas.payCount);

                        $("#hz_vipCount").html(datas.vipCount);
                        $("#hz_vipWater").html(datas.vipWater);
                        $("#hz_vipAmt").html(datas.vipAmt);
                        $("#hz_vipRenewalFeeRate").html(datas.vipRenewalFeeRate+"%");

                        $("#hz_vipLost").html(datas.vipLost);
                        $("#hz_vipRetailRate").html(datas.vipRetailRate+"%");
                        $("#hz_vipSelfRetailRate").html(datas.vipSelfRetailRate+"%");
                        $("#hz_retailRate").html(datas.retailRate+"%");

                        $("#hz_teamFullClassRate").html(datas.teamFullClassRate+"%");
                        $("#hz_averagePayCount").html(datas.averagePayCount);
                    }
                    $('.modal-loading').hide();
                },
                error: function () {
                    alert("页面数据加载失败！");
                    $('.modal-loading').hide();
                }
            });
            
        });

        // 排行类数据
        $("#click_ph").click(function () {
            $("#ph_data_dox").show();
            $('.modal-loading').show();
            var sort_datarange1 = $("#sort_datarange1").val();
            var sort_datarange2 = $("#sort_datarange2").val();
            var sort_datarange3 = $("#sort_datarange3").val();
            var dateTimes = getNowThirtyDays();
            if (dateTimes.length > 0) {
                if (sort_datarange1.length == 0) {
                    $("#sort_datarange1").val(dateTimes);
                }
                if (sort_datarange2.length == 0) {
                    $("#sort_datarange2").val(dateTimes);
                }
                if (sort_datarange3.length == 0) {
                    $("#sort_datarange3").val(dateTimes);
                }
            }
            queryCoachSortData();
            queryCourseSortData();
            queryTeamFullClassRateSort();
            
        })
        // 查询
        $("#btn_query").click(function () {
            // 点击查询的时候时间不能为空
            var type = $("#types").val();
            var dateTime = null;
            var startTime = null;
            var endTime = null;
            if (type == 1) {
                dateTime = $("#exampleInputEmail").val();
            } else if (type == 2) {
                dateTime = $("#Week").val();
            } else if (type == 3) {
                dateTime = $("#yearMonth").val();
            }
            if (dateTime.length < 1) {
                alert("时间不能为空");
                return false;
            }
            data_level_one();
        });
        var bool_len = bool_select();
        if (bool_len == 0) {
            $("#exampleInputEmail").val(moment().startOf('day').format('YYYY-MM-DD')+'~'+moment().startOf('day').format('YYYY-MM-DD'));
            data_level_one();
        }
        //
        $("input:radio[name='options']").change(function () {
            var timeType = this.value;
            if (timeType == 3 || timeType == "3") {
            	$("#vip_jl").show(900);
                $("#vip_xf").show(1000);
            } else {
            	$("#vip_jl").hide(900);
                $("#vip_xf").hide(1000);
            }

        });
        var type = $("input[name='options']:checked").val();
        if (type != 3) {
        	$("#vip_jl").hide(900);
            $("#vip_xf").hide(1000);
        }
		
		
    })
    function bool_select() {
    	var type = $("#types").val();
        var dateTime = null;
        var startTime = null;
        var endTime = null;
        if (type == 1) {
            dateTime = $("#exampleInputEmail").val();
        } else if (type == 2) {
            dateTime = $("#Week").val();
        } else if (type == 3) {
            dateTime = $("#yearMonth").val();
        }
        return dateTime;
    }
    function data_level_one() {
    	var type = $("#types").val();
    	$('.modal-loading').show();
        var dateTime = null;
        var startTime = null;
        var endTime = null;
        if (type == 1) {
            dateTime = $("#exampleInputEmail").val();
        } else if (type == 2) {
            dateTime = $("#Week").val();
        } else if (type == 3) {
            dateTime = $("#yearMonth").val();
        }
        $("#orderCount").html("");
        $("#orderWater").html("");
        $("#orderRevenueAmt").html("");
        $("#orderPayNumber").html("");
 		$("#vipNum").html("");
        $("#vipWater").html("");
        $("#vipAmt").html("");
        $("#vipLost").html("");
  		$("#vipConversionRate").html("%");
        $("#vipSelfConversionRate").html("%");
        $("#retailRechargeRate").html("%");
        $("#courseCount").html("");
 		$("#teamFullClassRate").html("%");
      	$("#averagePayCount").html("");
      	$("#vipRenewalFeeRate").html("%");
      	$("#coachAmt").html("");
        $.ajax({
            url: 'data_level_one',
            data: {
                "type": type,
                "dateTime": dateTime
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.ret == 0) {
                    var datas = data.data;
                    $("#orderCount").html(datas.orderCount);
                    $("#orderWater").html(datas.orderWater);
                    $("#orderRevenueAmt").html(datas.orderRevenueAmt);
                    $("#orderPayNumber").html(datas.orderPayNumber);
                    if (datas.type == 1 || datas.type == '1') {
                        $("#dateTime").html('按日查询数据（' + datas.dateTime + '）')
                    } else if (datas.type == 2 || datas.type == '2') {
                        $("#dateTime").html('按周查询数据（' + datas.dateTime + '）')
                    } else if (datas.type == 3 || datas.type == '3') {
                        $("#dateTime").html('按月查询数据（' + datas.dateTime + '）')
                    }
                }
                $('.modal-loading').hide();

            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });

        // 22
        $.ajax({
            url: 'data_level_tow',
            data: {
                "type": type,
                "dateTime": dateTime
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.ret == 0) {
                    var datas = data.data;
                    $("#vipNum").html(datas.vipNum);
                    $("#vipWater").html(datas.vipWater);
                    $("#vipAmt").html(datas.vipAmt);
                    $("#vipLost").html(datas.vipLost);
                }
            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });
        // 33
        $.ajax({
            url: 'data_level_three',
            data: {
                "type": type,
                "dateTime": dateTime
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                
                if (data.ret == 0) {
                    var datas = data.data;
                    $("#vipConversionRate").html(datas.vipConversionRate+"%");
                    $("#vipSelfConversionRate").html(datas.VipSelfConversionRate+"%");
                    $("#retailRechargeRate").html(datas.retailRechargeRate+"%");
                    $("#courseCount").html(datas.courseCount);
                }
            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });
        // 44
        $.ajax({
            url: 'data_level_four',
            data: {
                "type": type,
                "dateTime": dateTime
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
            	  $("#teamFullClassRate").html("%");
                  $("#averagePayCount").html();
                  $("#vipRenewalFeeRate").html("%");
                  $("#coachAmt").html();
                if (data.ret == 0) {
                    var datas = data.data;
                    $("#teamFullClassRate").html(datas.teamFullClassRate+"%");
                    $("#averagePayCount").html(datas.averagePayCount);
                    $("#vipRenewalFeeRate").html(datas.vipRenewalFeeRate+"%");
                    $("#coachAmt").html(datas.coachAmt);
                }
            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });

    }

    // 教练复购率排名
    function queryCoachSortData() {
        var sort_datarange1 = $("#sort_datarange1").val();
        $.ajax({
            url: 'ranking_to_coach',
            data: {
                "dateTime": sort_datarange1
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.ret == 0) {
                    var datas = data.data;
                    var html = '';
                    var num = 1;
                    for (i = 0; i < datas.coachList.length; i++) {
                        html = html +
                            '<tr><td>' + num + '</td>' +
                            '<td>' + datas.coachList[i].name + '</td>' +
                            '<td><span class="label label-info">' + datas.coachList[i].rate + '%</span></td></tr>';
                        num++;
                    }
                    $("#coachDataDiv").html(html);
                }
                $('.modal-loading').hide();
            },
            error: function () {
                alert("页面数据加载失败！");
                $('.modal-loading').hide();
            }
        });
    }
    // 课程复购率排名
    function queryCourseSortData() {
        var sort_datarange2 = $("#sort_datarange2").val();
        $.ajax({
            url: 'ranking_to_course',
            data: {
                "dateTime": sort_datarange2
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                
                if (data.ret == 0) {
                    var datas = data.data;
                    var html = '';
                    var num = 1;
                    for (i = 0; i < datas.courseList.length; i++) {
                        html = html +
                            '<tr><td>' + num + '</td>' +
                            '<td>' + datas.courseList[i].name + '</td>' +
                            '<td><span class="label label-info">' + datas.courseList[i].rate + '%</span></td></tr>';
                        num++;
                    }
                    $("#courseDataDiv").html(html);
                }

            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });
    }
    // 团课满课率排名
    function queryTeamFullClassRateSort() {
        var sort_datarange3 = $("#sort_datarange3").val();
        $.ajax({
            url: 'ranking_to_team',
            data: {
                "dateTime": sort_datarange3
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                
                if (data.ret == 0) {
                    var datas = data.data;
                    var html = '';
                    var num = 1;
                    for (i = 0; i < datas.teamFullList.length; i++) {
                        html = html +
                            '<tr><td>' + num + '</td>' +
                            '<td>' + datas.teamFullList[i].name + '</td>' +
                            '<td><span class="label label-info">'+ datas.teamFullList[i].rate + '%</span></td></tr>';
                        num++;
                    }
                    $("#teamCourseDataDiv").html(html);
                  	//分页
                    /* new Page({
                        parent: $("#u_page_list"),
                        nowPage: 1,
                        pageSize: 20,
                        totalCount: num-1,
                        setting: {
                            defaultPage: 5,//默认显示可点击分页的个数
                            firstPageText: "首页",
                            prevPageText: "上一页",
                            nextPageText: "下一页",
                            lastPageText: "尾页"
                        },
                        callback: function (nowPage, totalPage) {
                        	queryTeamFullClassRateSort();
                        }
                    }); */
                }
            },
            error: function () {
                alert("页面数据加载失败！");
            }
        });
    }

</script>

</@body.page>
</html>